<?php
include_once "database.php";
header("Content-type:text/html;charset=gb2312");
if(isset($_POST['type'])){
	$type = $_POST['type'];
	$database = new db();
	if($type == "add"){
		$reg_name = $_POST['reg_name'];
		$reg_pw = $_POST['reg_pw'];
		$reg_email = $_POST['reg_email'];	
		echo $database->add($reg_name,$reg_pw,$reg_email);
	}
	else if($type == "chk"){
		$result = $database->check($_POST['chkStr'],$_POST['pw']);
		if($result != "")
			echo "{\"rc\":100,\"un\":" . $result . "}";
		else echo "{\"rc\":101}";		
	}
	else 
		echo "{\"rc\":101}";	
}
else 
	echo "{\"rc\":101}";
?>
